<template>
  <div class="wrapper">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <h3 style="float: left">项目申请基本信息修改</h3>
          <el-button
            size="small"
            round
            style="background-image: linear-gradient(#e9f0e9, white);float:right; margin: 14px 50px 0 0;"
            @click="back()"
            >返 回</el-button
          >
          <!-- <h5 class="title">您当前修改的项目是<em style="color: #367fa9">{{title}}</em></h5> -->
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="intro">
          <font size="4.7" face="微软雅黑">
            <strong>基本数据</strong>
          </font>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form
          style="padding-left:180px"
          :model="form"
          size="medium"
          ref="form"
          label-width="100px"
          class="demo-ruleForm"
          :disabled="false"
        >
          <el-col :span="7">
            <el-form-item label="课题名称" prop="title">
              <el-input
                class="cell-width"
                v-model="form.title"
                prefix-icon="el-icon-postcard"
                placeholder="请勿超过40个汉字"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="研究方向" prop="research_direction">
              <el-input
                class="cell-width"
                v-model="form.research_direction"
                prefix-icon="el-icon-rank"
                placeholder="请输入研究方向"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="主题词" prop="theme">
              <el-input
                class="cell-width"
                v-model="form.theme"
                prefix-icon="el-icon-attract"
                placeholder="请输入主题词，以分号隔开（至多四个）"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="工作单位" prop="unit">
              <el-input
                class="cell-width"
                v-model="form.unit"
                prefix-icon="el-icon-school"
                placeholder="请按单位和部门公章填写全称"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="计划完成时间">
              <el-date-picker
                v-model="form.finish_time"
                type="date"
                prefix-icon="el-icon-date"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="字数">
              <el-input
                style="width: 77%"
                v-model.number="form.word_count"
                prefix-icon="el-icon-document-copy"
                placeholder="请输入最终成果字数"
              ></el-input>
              <span>
                <strong>(千字)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="通讯地址" prop="unit">
              <el-input
                class="cell-width"
                v-model="form.postal_address"
                prefix-icon="el-icon-school"
                placeholder="请按照地区名，街道名及门牌号填写"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="邮政编码" prop="unit">
              <el-input
                class="cell-width"
                v-model.number="form.post_code"
                prefix-icon="el-icon-school"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="21">
            <el-tooltip
              class="item"
              effect="dark"
              content="至少勾选一项至多两项"
              placement="top-start"
            >
              <el-form-item label="最终成果形式">
                <el-checkbox-group
                  style="width:100%"
                  v-model="result"
                  :min="1"
                  :max="2"
                  @change="mulCheck"
                >
                  <el-checkbox
                    v-for="item in resultAll"
                    :label="item"
                    :key="item"
                    >{{ item }}</el-checkbox
                  >
                </el-checkbox-group>
              </el-form-item>
            </el-tooltip>
          </el-col>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" class="apply_expense">经费预算（单位：万元）</el-col>
      <el-col :span="24">
        <el-form
          :model="formExpense"
          label-width="100px"
          style="padding-left: 10%"
        >
          <el-col :span="5">
            <el-form-item label="书本费" prop="book_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.book_fee"
                  placeholder="请输入书本费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途">
              <el-input
                class="cell-width"
                v-model="formExpense.book_fee_basis"
                placeholder="请输入书本费预算的依据及用途"
                type="textarea"
                maxlength="200"
                show-word-limit
                autosize
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="数据采集费" prop="book_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.data_fee"
                  placeholder="请输入采集费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.data_fee_basis"
                placeholder="请输入数据采集费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="差旅费" prop="travel_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.travel_fee"
                  placeholder="请输入差旅费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="travel_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.travel_fee_basis"
                placeholder="请输入差旅费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="会议费" prop="meeting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.meeting_fee"
                  placeholder="请输入会议费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="meeting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.meeting_fee_basis"
                placeholder="请输入会议费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="国际合作费" prop="international_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.international_fee"
                  placeholder="请输入合作费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="international_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.international_fee_basis"
                placeholder="请输入国际交流合作费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="设备费" prop="equipment_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.equipment_fee"
                  placeholder="请输入设备费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="equipment_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.equipment_fee_basis"
                placeholder="请输入设备费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="专家咨询费" prop="consulting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.consulting_fee"
                  placeholder="请输入咨询费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="consulting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.consulting_fee_basis"
                placeholder="请输入专家咨询费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="劳务费" prop="labour_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.labour_fee"
                  placeholder="请输入劳务费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="labour_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.labour_fee_basis"
                placeholder="请输入劳务费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="印刷费" prop="print_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.print_fee"
                  placeholder="请输入印刷费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.print_fee_basis"
                placeholder="请输入印刷费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="管理费" prop="administration_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.administration_fee"
                  placeholder="请输入管理费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="administration_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.administration_fee_basis"
                placeholder="请输入管理费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="其他支出" prop="other_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.other_fee"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="other_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.other_fee_basis"
                placeholder="请输入其他支出预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div style="text-align:center">
          <h4 style="display: inline-block">主要参与人员修改</h4>
          <el-tooltip
            class="item"
            effect="dark"
            content="点击添加人员信息,至多4人"
            placement="top-start"
          >
            <el-button
              size="mini"
              style="margin-left: 10px"
              type="primary"
              icon="el-icon-plus"
              @click="
                dialogFormVisible = true
                addPer()
              "
            ></el-button>
          </el-tooltip>
        </div>
      </el-col>
      <!-- <el-col :span="7">
      <el-tooltip class="item" effect="dark" content="点击添加人员信息" placement="top-start">
        <el-button
          size="mini"
          style="float:right"
          type="primary"
          icon="el-icon-plus"
          @click="dialogFormVisible = true"
        ></el-button>
      </el-tooltip>
      </el-col> -->
      <el-col :span="24" class="people-table">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="index" type="index" label="id" width="40">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="150">
          </el-table-column>
          <el-table-column
            :formatter="sexShow"
            prop="sex"
            label="性别"
            width="50"
          >
          </el-table-column>
          <el-table-column prop="idnumber" label="身份证号" width="180">
          </el-table-column>
          <el-table-column prop="jobrank" label="职称" width="150">
          </el-table-column>
          <el-table-column prop="expertise" label="研究专长" width="170">
          </el-table-column>
          <el-table-column prop="edu" label="学历" width="130">
          </el-table-column>
          <el-table-column prop="task" label="承担任务"> </el-table-column>
          <el-table-column label="操作" width="">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="success"
                icon="el-icon-edit"
                @click="
                  dialogFormVisible = true
                  updatePeo(scope.row)
                "
                >修改</el-button
              >
              <el-button
                size="mini"
                type="warning"
                icon="el-icon-delete"
                @click="deletePeo(scope.row)"
                >删除</el-button
              >
            </template>
            <el-dialog
              width="35%"
              title="人员信息"
              :visible.sync="dialogFormVisible"
              :append-to-body="true"
            >
              <el-form :model="formPer" ref="formPer" :rules="rulesOne">
                <table class="content" border cellspacing="0">
                  <tr>
                    <td class="left"><span class="red">*</span>姓名</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="参与人员的姓名，请认真填写"
                        v-model="formPer.name"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>性别</td>
                    <td class="right">
                      <el-select v-model="formPer.sex">
                        <el-option
                          v-for="item in sexs"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                        <!-- <el-option value="男">男</el-option>
                        <el-option value="女">女</el-option> -->
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>身份证号</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请按照身份证号格式输入"
                        v-model="formPer.idnumber"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <!-- <tr>
                    <td class="left"><span class="red">*</span>出生年月</td>
                    <td class="right">
                      <el-input type="text" placeholder="请按照1990-09-11格式输入" v-model="formPer.birth" clearable></el-input>
                    </td>
                  </tr>-->
                  <tr>
                    <td class="left"><span class="red">*</span>职称</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入职称名称"
                        v-model="formPer.jobrank"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>研究专长</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入研究专长"
                        v-model="formPer.expertise"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>承担任务</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入承担任务"
                        v-model="formPer.task"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>学历</td>
                    <td class="right">
                      <el-select
                        type="text"
                        placeholder="请选择学历"
                        v-model="formPer.edu"
                        clearable
                      >
                        <el-option
                          v-for="item in edus"
                          :key="item.value"
                          :label="item.label"
                          :value="item.label"
                        ></el-option>
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>学位</td>
                    <td class="right">
                      <el-select
                        type="text"
                        placeholder="请选择学位"
                        v-model="formPer.degree"
                        clearable
                      >
                        <el-option
                          v-for="item in degrees"
                          :key="item.value"
                          :label="item.label"
                          :value="item.label"
                        ></el-option>
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>工作单位</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请按单位和部门公章填写全称"
                        v-model="formPer.unit"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                </table>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="servePer(formPer)"
                  >确 定</el-button
                >
              </div>
            </el-dialog>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" class="apply_expense" style="padding-top:20px"
        >申报成果介绍</el-col
      >
      <el-col :span="22">
        <template>
          <div class="editor">
            <!-- this.$refs.ue.getUEContent()取编辑框数据 -->
            <UE :defaultMsg="defaultMsg" :config="config" ref="ue"></UE>
          </div>
        </template>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" style="text-align:center;padding-top: 40px">
        <el-button type="primary" @click="submitCheck(form, subproject)"
          >提交修改</el-button
        >
      </el-col>
    </el-row>
  </div>
</template>

<script>
import http from '../../../../assets/js/http.js'
import UE from '../../../ue.vue'
const Options = ['专著', '教材', '论文', '课题报告']
export default {
  props: {},
  data() {
    return {
      partner: [],
      dialogFormVisible: false,
      tableData: [],
      resultAll: Options,
      options1: [],
      result: [],
      userInfo: Lockr.get('userInfo'),
      support: Lockr.get('support'),
      editor: null,
      defaultMsg: '',
      config: {
        initialFrameHeight: 150,
        initialFrameWidth: null
      },
      title: '',
      edus: [
        {
          label: '博士研究生',
          value: '1'
        },
        {
          label: '硕士研究生',
          value: '2'
        },
        {
          label: '大学本科',
          value: '3'
        },
        {
          label: '大学专科',
          value: '4'
        },
        {
          label: '高中',
          value: '5'
        },
        {
          label: '其他',
          value: '6'
        }
      ],
      degrees: [
        {
          label: '博士',
          value: '1'
        },
        {
          label: '硕士',
          value: '2'
        },
        {
          label: '学士',
          value: '3'
        },
        {
          label: '其他',
          value: '4'
        }
      ],
      sexs: [
        {
          label: '男',
          value: 1
        },
        {
          label: '女',
          value: 2
        }
      ],
      form: {
        title: '',
        theme: '',
        research_direction: '',
        finish_time: '',
        word_count: '',
        unit: '',
        postal_address: '',
        post_code: '',
        achievement: '',
        id: ''
      },
      tips: {
        titleTips: '课题名称',
        themeTips: '主题词',
        research_directionTips: '研究方向',
        finish_timeTips: '计划完成时间',
        word_countTips: '字数',
        unitTips: '工作单位',
        postal_addressTips: '通讯地址',
        post_codeTips: '邮编'
      },
      formExpense: {
        book_fee: '',
        book_fee_basis: '',
        data_fee: '',
        data_fee_basis: '',
        travel_fee: '',
        travel_fee_basis: '',
        international_fee: '',
        international_fee_basis: '',
        labour_fee: '',
        labour_fee_basis: '',
        administration_fee: '',
        administration_fee_basis: '',
        print_fee: '',
        print_fee_basis: '',
        equipment_fee: '',
        equipment_fee_basis: '',
        consulting_fee: '',
        consulting_fee_basis: '',
        meeting_fee: '',
        meeting_fee_basis: '',
        other_fee: '',
        other_fee_basis: ''
      },
      formPer: {
        name: '',
        sex: 0,
        idnumber: '',
        task: '',
        // birth: '',
        jobrank: '',
        expertise: '',
        edu: '',
        degree: '',
        unit: ''
      },
      tipsOne: {
        nameTips: '姓名',
        sexTips: '性別',
        idnumberTips: '身份证号',
        taskTips: '承担任务',
        jobrankTips: '职务',
        expertiseTips: '研究专长',
        eduTips: '学历',
        degreeTips: '学位',
        unitTips: '工作单位'
      },
      status: '0',
      checkResultOne: '',
      last: '',
      ids: [],
      index: ''
    }
  },
  methods: {
    // 返回上一个界面
    back() {
      this.$router.push({
        name: 'detailpro',
        params: {
          id: this.$route.params.id,
          saveData: this.$route.params.saveData,
          reData: this.$route.params.reData
        }
      })
    },
    // 初始化函数
    init() {
      this.getSupportType()
    },
    // 多选框变化时触发函数
    mulCheck(value) {
      // console.log(value)
      // console.log(this.result)
    },
    // 更新表格单人信息
    updatePeo(perMsg) {
      console.log(perMsg)
      this.index = this.tableData.indexOf(perMsg)
      this.last = 2
      let curList = JSON.parse(JSON.stringify(perMsg))
      this.formPer = curList
    },
    // 删除表格单人信息
    deletePeo(perMsg) {
      // console.log(perMsg)
      var rowind = this.tableData.indexOf(perMsg)
      let curList = JSON.parse(JSON.stringify(perMsg))
      // var index = -1
      this.$confirm('此操作将永久删除该成员, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          // 删除操作
          if (curList.id != undefined) {
            this.ids.push(curList.id)
          }
          this.partner.splice(rowind, 1)
          this.tableData = this.partner
          // let array = JSON.parse(JSON.stringify(this.partner))
          // for (let i = 0; i < array.length; i++) {
          //   console.log(array[i].id)
          //   if(curList.id === array[i].id) {
          //     index = i
          //     break
          //   }
          // }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 对于主要成员信息操作之前的验证
    check(curList) {
      this.checkResultOne = this.checkList(curList, [
        {
          name: 'jobrank',
          reg: ['notnull']
        },
        {
          name: 'name',
          reg: ['notnull']
        },
        {
          name: 'sex',
          reg: ['notnull']
        },
        {
          name: 'idnumber',
          reg: ['notnull']
        },
        // {
        //   'name':'task',
        //   'reg':['notnull']
        // },
        {
          name: 'expertise',
          reg: ['notnull']
        },
        {
          name: 'edu',
          reg: ['notnull']
        },
        {
          name: 'degree',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        }
      ])
    },
    // 增加人员信息
    addPer() {
      this.last = 1
      if (this.tableData.length >= 4) {
        _g.toastMsg('warning', '人数已达上限,不可再添加')
        this.dialogFormVisible = false
      } else {
        this.formPer = {}
      }
    },
    // dialog确定后保存人员信息入数组
    servePer(perMsg) {
      console.log(perMsg)
      let curList = JSON.parse(JSON.stringify(perMsg))
      this.check(curList)
      if (_g.j2s(this.checkResultOne) === '{}') {
        this.dialogFormVisible = false
        // console.log(this.partner)
        let array = JSON.parse(JSON.stringify(this.partner))
        if (this.last === 1) {
          // add
          array.push(curList)
          this.last = ''
        }
        if (this.last === 2) {
          // 对当前修改的成员的信息进行修改
          for (let i = 0; i < array.length; i++) {
            const element = array[i]
            if (i === this.index) {
              array[i] = curList
            }
          }
          this.last = ''
        }
        this.partner = array
        this.tableData = this.partner
        console.log(this.partner)
      } else {
        for (const key in this.checkResultOne) {
          this.dialogFormVisible = true
          _g.toastMsg('warning', this.tipsOne[key] + this.checkResultOne[key])
          break
        }
      }
    },
    // 获取项目类别的label
    // getSupportType() {
    //   let data = {}
    //   this.apiPost('admin/Report/DropdowmList', data).then((res) => {
    //     this.handelResponse(res, (data) => {
    //       Lockr.set('support', data.support)
    //     })
    //   })
    // },
    // 获取子项目所有相关信息便于查看
    getAllMsg() {
      let data = {
        id: this.$route.params.id
      }
      // console.log(data)
      this.apiPost('admin/Report/ChildrenList', data).then(res => {
        this.handelResponse(res, data => {
          console.log(res)
          this.tableData = data.partner
          this.partner = data.partner
          this.form = data.subproject[0]
          this.formExpense = data.fund[0]
          this.title = data.subproject[0].title
          this.form.postal_address = data.train[0].address
          this.result = data.subproject[0].result.split(',')
          if (data.subproject[0].support === 0) {
            this.form.support = '教育厅还未最终敲定'
          } else {
            this.form.support = this.support[this.form.support].title
          }
          this.defaultMsg = data.subproject[0].achievement
          this.form.achievement = data.subproject[0].achievement
          window.UE.getEditor('editor').setContent(this.defaultMsg)
        })
      })
    },
    // 性别1男2女
    sexShow(row) {
      var sex = ''
      if (row.sex === 1) {
        sex = '男'
      } else if (row.sex === 2) {
        sex = '女'
      }
      return sex
    },
    // 提交前的验证
    submitCheck(form, subproject) {
      var checkResult = this.checkList(form, [
        {
          name: 'title',
          reg: ['notnull']
        },
        {
          name: 'theme',
          reg: ['notnull']
        },
        {
          name: 'research_direction',
          reg: ['notnull']
        },
        {
          name: 'finish_time',
          reg: ['notnull']
        },
        {
          name: 'word_count',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        },
        {
          name: 'postal_address',
          reg: ['notnull']
        }
      ])
      if (_g.j2s(checkResult) === '{}') {
        if (this.$refs.ue.getUEContent() === '') {
          _g.toastMsg('warning', '成功介绍不能为空')
        } else {
          this.submitUpdate()
        }
      } else {
        for (const key in checkResult) {
          _g.toastMsg('warning', this.tips[key] + checkResult[key])
          break
        }
      }
    },
    // 提交修改的数据
    submitUpdate() {
      this.timeDeal()
      console.log(this.ids)
      this.form.result = this.result
      this.form.achievement = this.$refs.ue.getUEContent()
      let data = {
        fund: this.formExpense,
        subproject: this.form,
        partner: this.partner,
        ids: this.ids
      }
      console.log(data)
      this.apiPost('admin/Report/TrainRevise', data).then(res => {
        this.handelResponse(res, data => {
          console.log(res)
          _g.toastMsg('success', '项目申报修改成功')
          this.$router.push({
            name: 'detailpro',
            params: { id: this.$route.params.pro_id }
          })
        })
      })
    },
    // 表单日期格式处理
    timeDeal() {
      let date = new Date(this.form.finish_time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.finish_time = year + '-' + month + '-' + day
    }
  },
  created() {
    _g.closeGlobalLoading()
    // this.init()
    this.getAllMsg()
  },
  watch: {},
  computed: {},
  components: { UE },
  mounted() {},
  mixins: [http]
}
</script>
<style scoped>
.wrapper {
  position: relative;
  border-radius: 3px;
  background: #fff;
  border-top: 3px solid #d2d6de;
  margin-bottom: 20px;
  width: 100%;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  border-top-color: #3c8dbc;
  padding-bottom: 50px;
}
.header {
  padding-left: 15px;
}
.title {
  padding: 30px 40px 0 0;
  float: right;
}
.intro {
  text-align: center;
  background-color: #add5fe;
  border-radius: 4px 4px 0 0;
  line-height: 30px;
  margin-bottom: 30px;
}
.cell-width {
  width: 90%;
}
.apply_expense {
  padding-bottom: 20px;
  font-family: '微软雅黑';
  font-weight: 800;
  text-align: center;
}
.editor {
  padding: 0 3.5% 0 12.5%;
}
.left {
  width: 18%;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 32%;
  padding: 4px;
}
.red {
  padding-right: 5px;
}
.content {
  margin: 0 auto;
  border-color: #e8f6f9;
  font-size: 14px;
}
.expense-width {
  width: 70%;
}
.people-table {
  padding: 0 11.4% 0 11.4%;
}
.left {
  width: 200px;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 400px;
  padding: 4px;
}
.red {
  color: red;
  padding-right: 3px;
}
.content {
  border-color: #e8f6f9;
}
.content tr:nth-child(even) {
  background: #fff;
}
.content tr:nth-child(odd) {
  background: #f2f9ff;
}
</style>
